﻿
@{
    Layout = null;
    var flag = ViewBag.success;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
    <style>
        .log {
            width: 200px;
            height: 400px;
            margin: 0 auto;
        }

        input {
            line-height: 30px;
            margin: 10px auto;
            width: 80%;
        }
    </style>
</head>
<body>
    <div class="log">
        <div id="su">@ViewBag.success</div>
        <p>首先，可以使用window.opener来引用打开父网页的window</p><p id="fartherWindowLocation">https://www.html.cn/demo/window-tongxin/</p>
        <form>
            <div><span>登陆</span></div>
            <input name="name" placeholder="用户名" />
            <input name="pwd" type="password" placeholder="密码" />
            <input type="submit" value="登陆" />

        </form>
        <button id="close">关闭</button>
    </div>
    <script type="text/javascript">
        var fartherWindow = window.opener;        
        document.getElementById("fartherWindowLocation").innerHTML = fartherWindow.location.href;
        document.getElementById("close").onclick=function(){
            fartherWindow.document.getElementById("login").innerHTML="子窗口操作父窗口！window.opener";
            window.close();
        }
        window.onload = function () {
            var s = document.getElementById('su').innerHTML;
            window.opener.document.getElementById('login').innerHTML="123";
        }
    </script>
    <script type="text/javascript">
            //跨域 iframe+window.name
            var person = {
                name: 'wayne zhu',
                age: 22,
                school: 'xjtu'
            }
            window.name = JSON.stringify(person)
    </script>

</body>
</html>
